package com.example.common;

public class Result<T> {
    private int status;
    private String message;
    private T data;

    public Result(){

    }

    public Result(int status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public static Result ok(){
        return new Result(200, "success", null);
    }

    public static Result ok(String message){
        return new Result(200, message, null);
    }

    public static <T> Result data(T data){
        return new Result(200, "success", data);
    }

    public static Result error(){
        return new Result(500, "error", null);
    }

    public static Result error(String message){
        return new Result(500, message, null);
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
